import qs from 'qs';

export default{
    data(){
        return{
			authShow: false,
			testDomain: ""
        }
    },
    methods: {
		async getAuthorizeUrl(scope) {
			let search = location.search.substr(1, location.search.length)
			let searchs = qs.parse(search)
			delete searchs.code
			delete searchs.state
			searchs.scope = scope
			let redirect_uri = location.protocol + "//" + location.host + location.pathname + "?" + qs.stringify(searchs)
			let param = {
				appid: "wx9b21b76cf18ef3f0",
				redirect_uri,
				response_type: 'code',
				scope,
				state: 'STATE'
			}
			if (scope == "snsapi_userinfo") {
				param['forcePopup'] = false
				param['forceSnapShot'] = false
			}
			return `https://open.weixin.qq.com/connect/oauth2/authorize?` + qs.stringify(param) + "#wechat_redirect"
		}
    }
}